#ifndef SDK_OHOS_OHOS_RTP_SENDER_H_
#define SDK_OHOS_OHOS_RTP_SENDER_H_

#include "api/rtp_sender_interface.h"
#include "api/scoped_refptr.h"
#include "api/ohos_rtp_sender_interface.h"
#include "api/ohos_peer_connection_factory_interface.h"

namespace ohoswebrtc {

class OHOSRtpSender : public OHOSRtpSenderInterface {
 public:
  OHOSRtpSender(rtc::scoped_refptr<webrtc::RtpSenderInterface> rtp_sender, rtc::scoped_refptr<OHOSPeerConnectionFactoryInterface> peer_connection_factory);
  virtual ~OHOSRtpSender();

  /** Returns true if successful in setting the track. Fails if an audio track is set on a video RtpSender, or vice-versa. */
  bool set_track(rtc::scoped_refptr<OHOSMediaTrackInterface> track) override;

   /** The RTCMediaStreamTrack associated with the sender. */
  rtc::scoped_refptr<OHOSMediaTrackInterface> track() const override;

  /**The dtlsTransport attribute exposes the DTLS transport on which the media is sent. It may be null. */
  rtc::scoped_refptr<webrtc::DtlsTransportInterface> dtls_transport() const override {
    return rtp_sender_->dtls_transport();
  }

  /**Returns primary SSRC used by this sender for sending media. Returns 0 if not yet determined. */
  uint32_t ssrc() const override {
    return rtp_sender_->ssrc();
  } 

  /**Media type for Audio or video receiver */
  cricket::MediaType media_type() const override {
    return rtp_sender_->media_type();
  }
  
  /** Not to be confused with "mid", this is a field we can temporarily use to uniquely identify a receiver until we implement Unified Plan SDP.*/
  const std::string send_id() const override {
    return rtp_sender_->id();
  }

  /** Set stream ids, eliminating duplicates in the process.*/
  const std::vector<std::string> stream_ids() const override {
    return rtp_sender_->stream_ids();
  }
  
  void SetStreams(const std::vector<std::string> stream_ids) const override {
    rtp_sender_->SetStreams(stream_ids);
  }

  /**Returns the list of encoding parameters that will be applied when the SDP local description is set */
  std::vector<webrtc::RtpEncodingParameters> init_send_encodings() const override {
    return rtp_sender_->init_send_encodings();
  }

  webrtc::RtpParameters parameters() const override {
    return rtp_sender_->GetParameters();
  }
  
  bool set_parameters(webrtc::RtpParameters &parameters) override {
    return rtp_sender_->SetParameters(parameters).ok();
  }

  /** native RtpSenderInterface */
  rtc::scoped_refptr<webrtc::RtpSenderInterface> rtp_sender() const override {
    return rtp_sender_;
  }
  
  /** native DtmfSenderInterface */
  rtc::scoped_refptr<webrtc::DtmfSenderInterface> dtmf_sender() const override {
    return rtp_sender_->GetDtmfSender();
  }
  
  /** Sets a user defined frame encryptor that will encrypt the entire frame
  * before it is sent across the network. This will encrypt the entire frame
  * using the user provided encryption mechanism regardless of whether SRTP is enabled or not
  **/
  void SetFrameEncryptor(rtc::scoped_refptr<webrtc::FrameEncryptorInterface> frame_encryptor) override {
    rtp_sender_->SetFrameEncryptor(frame_encryptor);
  }

  /** Returns a pointer to the frame encryptor set previously by the
   * user. This can be used to update the state of the object.
  **/
  rtc::scoped_refptr<webrtc::FrameEncryptorInterface> GetFrameEncryptor() override {
    return rtp_sender_->GetFrameEncryptor();
  }
  
  void SetEncoderToPacketizerFrameTransformer(rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer) override {
    rtp_sender_->SetEncoderToPacketizerFrameTransformer(frame_transformer);
  }
  
  void SetEncoderSelector(
      std::unique_ptr<webrtc::VideoEncoderFactory::EncoderSelectorInterface>
          encoder_selector) override;
  
  /** Default implementation of SetFrameTransformer. */
  void SetFrameTransformer(rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer) override {
    rtp_sender_->SetFrameTransformer(frame_transformer);
  }
  

 private:
  rtc::scoped_refptr<webrtc::RtpSenderInterface> rtp_sender_;
  rtc::scoped_refptr<OHOSPeerConnectionFactoryInterface> peer_connection_factory_;
};

}  

#endif  